package com.ccl.iot;

/**
 * 函数调用结果定义
 */
public enum EIOT_RESULT {
	;
	public static final int EIOT_RESULT_OK = 0;	//无任何错误
	
	/*	Base error	*/
	public static final int EIOT_RESULT_BASE_ERROR = 0x10000000;
	public static final int EIOT_RESULT_TIMEOUT = EIOT_RESULT_BASE_ERROR + 1;	//连接超时
	public static final int EIOT_RESULT_FAILED = EIOT_RESULT_BASE_ERROR + 2;	//失败
	public static final int EIOT_RESULT_INVALID = EIOT_RESULT_BASE_ERROR + 3;	//无效操作
	public static final int EIOT_RESULT_PARAMETER_INVALID = EIOT_RESULT_BASE_ERROR + 4;	//参数无效
	public static final int EIOT_RESULT_NO_EFFECT = EIOT_RESULT_BASE_ERROR + 5;	//未产生效果
	public static final int EIOT_RESULT_IN_USE = EIOT_RESULT_BASE_ERROR + 6;	//使用中
	public static final int EIOT_RESULT_ALL_IN_USE = EIOT_RESULT_BASE_ERROR + 7;	//全部使用中
	public static final int EIOT_RESULT_EXIST = EIOT_RESULT_BASE_ERROR +8;	//已存在
	public static final int EIOT_RESULT_NOT_EXIST = EIOT_RESULT_BASE_ERROR + 9;	//不存在

	/*	General error	*/
	public static final int EIOT_RESULT_GENERAL_ERROR = 0x20000000;
	public static final int EIOT_RESULT_GENERAL_UNSUPPORT = EIOT_RESULT_GENERAL_ERROR + 1;	//操作不被支持
	public static final int EIOT_RESULT_GENERAL_BAD_STATUS = EIOT_RESULT_GENERAL_ERROR + 2;	//错误的状态下进行操作
	public static final int EIOT_RESULT_GENERAL_TRY_AGAIN = EIOT_RESULT_GENERAL_ERROR + 3;	//操作需要再试一次，通常发生在有相关安全考量的操作中，如设备重启及复位均需操作3次
	
	public static final int EIOT_RESULT_GENERAL_NOTIFY_ERROR = 0x20010000;
	public static final int EIOT_RESULT_GENERAL_NO_NOTIFY = EIOT_RESULT_GENERAL_NOTIFY_ERROR + 1;	//无通知信息
	
	public static final int EIOT_RESULT_GENERAL_PERMISSION_ERROR = 0x20100000;
	public static final int EIOT_RESULT_GENERAL_PERMISSION_WAITTING = EIOT_RESULT_GENERAL_PERMISSION_ERROR + 1;	//等待授权中
	public static final int EIOT_RESULT_GENERAL_PERMISSION_READ_ONLY = EIOT_RESULT_GENERAL_PERMISSION_ERROR + 2;	//权限只读
	public static final int EIOT_RESULT_GENERAL_PERMISSION_WRITE_ONLY = EIOT_RESULT_GENERAL_PERMISSION_ERROR + 3;	//权限只写
	public static final int EIOT_RESULT_GENERAL_PERMISSION_DENIED = EIOT_RESULT_GENERAL_PERMISSION_ERROR + 4;	//拒绝访问
	
	public static final int EIOT_RESULT_GENERAL_AUTHORIZE_ERROR = 0x20110000;
	public static final int EIOT_RESULT_GENERAL_AUTHORIZE_REJECT = EIOT_RESULT_GENERAL_AUTHORIZE_ERROR + 1;	//授权被驳回
	public static final int EIOT_RESULT_GENERAL_AUTHORIZE_STATE_INVALID = EIOT_RESULT_GENERAL_AUTHORIZE_ERROR + 2;	//无效的授权状态
	public static final int EIOT_RESULT_GENERAL_NO_AUTHORIZE_DEVICE = EIOT_RESULT_GENERAL_AUTHORIZE_ERROR + 3;	//无被授权的设备
	public static final int EIOT_RESULT_GENERAL_NO_AUTHORIZE_USER = EIOT_RESULT_GENERAL_AUTHORIZE_ERROR + 4;	//无被授权的用户
	
	public static final int EIOT_RESULT_GENERAL_DEVICE_ERROR = 0x20200000;
	public static final int EIOT_RESULT_GENERAL_DEVICE_OFFLINE = EIOT_RESULT_GENERAL_DEVICE_ERROR + 1;	//设备离线
	public static final int EIOT_RESULT_GENERAL_DEVICE_INFO_EXIST = EIOT_RESULT_GENERAL_DEVICE_ERROR + 2;	//相同名称的设备信息已存在
	public static final int EIOT_RESULT_GENERAL_NO_DEVICE_INFO = EIOT_RESULT_GENERAL_DEVICE_ERROR + 3;	//无设备信息
	public static final int EIOT_RESULT_GENERAL_NO_ONLINE_DEVICE = EIOT_RESULT_GENERAL_DEVICE_ERROR + 4;	//无在线设备
	public static final int EIOT_RESULT_GENERAL_NO_UPGRADE_DEVICE = EIOT_RESULT_GENERAL_DEVICE_ERROR + 5;	//无接受升级的设备
	public static final int EIOT_RESULT_GENERAL_DEVICE_NORESPONSE = EIOT_RESULT_GENERAL_DEVICE_ERROR + 6;	//设备无响应
	public static final int EIOT_RESULT_GENERAL_PATCH_UNSUPPORT = EIOT_RESULT_GENERAL_DEVICE_ERROR + 7;	//补丁不被支持
	public static final int EIOT_RESULT_GENERAL_PATCH_NEWEST = EIOT_RESULT_GENERAL_DEVICE_ERROR + 8;	//补丁已经是最新
	public static final int EIOT_RESULT_GENERAL_PATCH_SIZE_LIMIT = EIOT_RESULT_GENERAL_DEVICE_ERROR + 9;	//补丁数据大小限制
	
	public static final int EIOT_RESULT_GENERAL_USER_ERROR = 0x20210000;
	public static final int EIOT_RESULT_GENERAL_USER_OFFLINE = EIOT_RESULT_GENERAL_USER_ERROR + 1;	//用户离线
	public static final int EIOT_RESULT_GENERAL_USER_INFO_EXIST = EIOT_RESULT_GENERAL_USER_ERROR + 2;	//相同名称的用户信息已存在
	public static final int EIOT_RESULT_GENERAL_NO_USER_INFO = EIOT_RESULT_GENERAL_USER_ERROR + 3;	//无用户信息
	
	public static final int EIOT_RESULT_GENERAL_REGISTER_ERROR = 0x20300000;
	public static final int EIOT_RESULT_GENERAL_WRITE_ACCEPTED = EIOT_RESULT_GENERAL_REGISTER_ERROR + 1;	//寄存器写入已被服务器接受
	public static final int EIOT_RESULT_GENERAL_WRITE_UNACCEPTE = EIOT_RESULT_GENERAL_REGISTER_ERROR + 2;	//服务器不接受寄存器写入
	public static final int EIOT_RESULT_GENERAL_REGISTER_INVALID = EIOT_RESULT_GENERAL_REGISTER_ERROR + 3;	//无效的寄存器
	public static final int EIOT_RESULT_GENERAL_REGISTER_NO_CHANGE = EIOT_RESULT_GENERAL_REGISTER_ERROR + 4;	//寄存器无更改
	
	public static final int EIOT_RESULT_GENERAL_BATCH_ERROR = 0x20400000;
	public static final int EIOT_RESULT_GENERAL_BATCH_EXIST = EIOT_RESULT_GENERAL_BATCH_ERROR + 1;	//相同名称的批处理命令已存在
	public static final int EIOT_RESULT_GENERAL_NO_BATCH = EIOT_RESULT_GENERAL_BATCH_ERROR + 2;	//无批处理命令
	public static final int EIOT_RESULT_GENERAL_BATCH_NO_ITEM = EIOT_RESULT_GENERAL_BATCH_ERROR + 3;	//批处理命令无项目

	/*	Server error	*/
	public static final int EIOT_RESULT_SERVER_ERROR = 0x40000000;
	public static final int EIOT_RESULT_SERVER_CONNECT_TO_DB_FAILED = EIOT_RESULT_SERVER_ERROR + 1;	//连接到数据库失败
	public static final int EIOT_RESULT_SERVER_UPDATE_TO_DB_FAILED = EIOT_RESULT_SERVER_ERROR + 2;	//更新数据到数据库失败
	public static final int EIOT_RESULT_SERVER_GEN_UDID_FAILED = EIOT_RESULT_SERVER_ERROR + 3;	//生成UDID失败
	public static final int EIOT_RESULT_SERVER_BOOK_COMMSERVER_FAILED = EIOT_RESULT_SERVER_ERROR + 4;		//预订服务器失败
	public static final int EIOT_RESULT_SERVER_GEN_USER_SID_FAILED = EIOT_RESULT_SERVER_ERROR + 5;	//生成用户SID失败
	public static final int EIOT_RESULT_SERVER_GEN_SID_FAILED = EIOT_RESULT_SERVER_ERROR + 6;	//生成对话ID失败
	
	/*	Fatal error	*/
	public static final int EIOT_RESULT_FATAL_ERROR = 0x80000000;
	public static final int EIOT_RESULT_FATAL_QUOTA_FULL = EIOT_RESULT_FATAL_ERROR + 1;	//配额已满
	public static final int EIOT_RESULT_FATAL_DEVICE_INFO_INVALID = EIOT_RESULT_FATAL_ERROR + 2;	//无效的设备信息
	public static final int EIOT_RESULT_FATAL_REGISTER_SPACE_TOO_BIG = EIOT_RESULT_FATAL_ERROR + 3;	//寄存器尺寸太大
	public static final int EIOT_RESULT_FATAL_SECURITY_CODE_WRONG = EIOT_RESULT_FATAL_ERROR + 4;	//安全校验码错误
	public static final int EIOT_RESULT_FATAL_USER_INFO_INVALID = EIOT_RESULT_FATAL_ERROR + 5;	//无效的用户信息
	public static final int EIOT_RESULT_FATAL_OUT_OF_MEMORY = EIOT_RESULT_FATAL_ERROR + 5;	//内存不足
	
	public static final int EIOT_RESULT_FATAL_DEVICE_ERROR = 0x80100000;
	public static final int EIOT_RESULT_FATAL_DEVICE_INVALID = EIOT_RESULT_FATAL_DEVICE_ERROR + 1;	//无效的设备
	public static final int EIOT_RESULT_FATAL_DEVICE_EXIST = EIOT_RESULT_FATAL_DEVICE_ERROR + 2;	//设备已存在
	public static final int EIOT_RESULT_FATAL_DEVICE_ALREADY_IN = EIOT_RESULT_FATAL_DEVICE_ERROR + 3;	//设备已登入
	public static final int EIOT_RESULT_FATAL_DEVICE_FORBIDDEN = EIOT_RESULT_FATAL_DEVICE_ERROR + 4;	//设备被禁用

	public static final int EIOT_RESULT_FATAL_USER_ERROR = 0x80200000;
	public static final int EIOT_RESULT_FATAL_USER_NOLOGIN = EIOT_RESULT_FATAL_USER_ERROR + 1;//用户未登录
	public static final int EIOT_RESULT_FATAL_USER_INVALID = EIOT_RESULT_FATAL_USER_ERROR + 2;	//无效的用户
	public static final int EIOT_RESULT_FATAL_USER_EXIST = EIOT_RESULT_FATAL_USER_ERROR + 3;	//相同名称的用户已存在
	public static final int EIOT_RESULT_FATAL_USER_NOT_EXIST = EIOT_RESULT_FATAL_USER_ERROR + 4;	//用户不存在
	public static final int EIOT_RESULT_FATAL_USER_PASSWORD_WRONG = EIOT_RESULT_FATAL_USER_ERROR + 5;	//用户密码错误
	public static final int EIOT_RESULT_FATAL_USER_RELOGIN_LIMIT = EIOT_RESULT_FATAL_USER_ERROR + 6;	//重复登录受限
	public static final int EIOT_RESULT_FATAL_USER_FORBIDDEN = EIOT_RESULT_FATAL_USER_ERROR + 7;	//用户被禁用
	public static final int EIOT_RESULT_FATAL_USER_ANSWER_WRONG = EIOT_RESULT_FATAL_USER_ERROR + 8; //用户忘记密码问题回答错误

	public static final int EIOT_RESULT_UNKNOWN = 0xFFFFFFFF;	//未知错误
	
	/**
	 * 判断结果是否为权限错误
	 * @param aResult	-	需判断的结果
	 * @return true表示权限类错误，false表示非权限类错误
	 */
	public static boolean IOT_PERMISSION_ERROR(int aResult){
		return aResult >= EIOT_RESULT_GENERAL_PERMISSION_ERROR && aResult <= EIOT_RESULT_GENERAL_PERMISSION_DENIED;
	}
	
	/**
	 * 判断结果是否正确
	 * @param aResult	-	需判断的结果
	 * @return true表示结果为正确，false表示结果不正确
	 */
	public static boolean ISOK(int aResult){
		return aResult == EIOT_RESULT.EIOT_RESULT_OK;
	}
}
